﻿using DAL;
using MainOP;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static MainOP.FormMain;
namespace MainOP
{
    public partial class FormUserLoginInterface : Form
    {
        public FormUserLoginInterface()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.richTextBoxUser.Text.Trim().Length == 0)
            {
                MessageBox.Show("用户名不能为空！", "用户提示");
                this.richTextBoxUser.Focus();
                return;
            }
            if (this.textBox1.Text.Trim().Length == 0)
            {
                MessageBox.Show("密码不能为空！", "用户提示");
                this.textBox1.Focus();
                return;
            }
            Program.userlogin = UserManagement.GetUser(richTextBoxUser.Text, textBox1.Text);
            if (Program.userlogin.Admin == null)
            {
                MessageBox.Show("用户名或密码错误！", "用户提示");
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                MessageBox.Show("登陆成功！");
                FMOP.label2.Text = "当前登录用户：{0}\t\t  使用公司：空调国际  \t设备公司：重庆英之拓  \tPLC连接{1}  \t 版本号：V1.0";
                FMOP.label2.Text = string.Format(FMOP.label2.Text, Program.userlogin.Admin, "0"/*str*/); ;

            }

            this.Close();
        }

        private void FormUserLoginInterface_Load(object sender, EventArgs e)
        {

        }
    }
}
